#include<iostream>
#include<cstdio>

using namespace std;
long long n,l,r,ans=-1;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>l>>r;
	long long  yu=r%n,mo=l%n;
	if(yu==n-1||mo==n-1) cout<<n-1;
	else
	{
		long long  zq=yu+1;
		if(r-zq>=l) r-=zq;
		ans=max(r%n,ans);
		
		long long mq=n-mo-1;
		if(l+mq<=r) l+=mq;
		ans=max(l%n,ans);
		
		cout<<ans;
	}
	
	return 0;
}
